<?php

use app\assets\TableAsset;
use app\widgets\ManagerTableOp;
use app\models\KeyMap;
use yii\helpers\Html;
use yii\helpers\Url;
use app\models\UserConfig;
use app\widgets\LinkPager;
/**
 * @var $this yii\web\View
 * @var $apiList app\models\Api[]
 */

TableAsset::register($this);

$this->title = '订单列表';
$this->params['breadcrumbs'][] = '出库管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<?php echo Html::beginForm('?', 'get', ['class'=>'form-inline']);?>
    <div class="form-group">
        <a href="<?php echo Url::to(['/admin/outbound/order-edit']);?>" class="btn btn-success btn-sm">添加</a>
    </div>
<?php echo Html::endForm();?>
<table class="table table-striped table-bordered table-hover">
    <thead>
        <tr>
            <th class="center">
                <label class="pos-rel">
                    <input type="checkbox" class="ace" />
                    <span class="lbl"></span>
                </label>
            </th>
            <th>运营商</th>
            <th>套餐</th>
            <th>单价</th>
            <th>数量</th>
            <th>用户</th>
            <th>卡类型</th>
            <th>支付方式</th>
            <th>金额</th>
            <th>发票</th>
            <th>日期</th>
            <th>操作</th>
        </tr>
    </thead>

    <tbody>
        <?php foreach ($orderList as $order) {?>
            <tr>
                <td class="center"><label class="pos-rel"><input type="checkbox" class="ace" value="<?php echo $order->id;?>" /><span class="lbl"><?php echo $order->id;?></span></label></td>
                <td><?php echo Html::encode($order->isp->name);?></td>
                <td><?php echo Html::encode($order->package->name);?></td>
                <td><?php echo Html::encode($order->price);?></td>
                <td><?php echo Html::encode($order->number);?></td>
                <td><?php echo Html::encode($order->user->username);?></td>
                <td><?php echo Html::encode($order->cardtype->name);?></td>
                <td><?php $prepaidPostpaid = UserConfig::getConfig($order->user->id, 'prepaid_postpaid', '');
                    echo ['' => '', 'prepaid' => '预付费', 'postpaid' => '后付费'][$prepaidPostpaid];
                    ?></td>
                <td><?php echo Html::encode($order->amount);?></td>
                <td><?php echo KeyMap::getValue('yes_no', $order->need_invoice);?></td>
                <td><?php echo Yii::$app->formatter->asDateTime($order->create_time);?></td>
                <td><?php echo ManagerTableOp::widget(['items' => [
                        ['icon' => 'fa fa-pencil', 'href' => Url::to(['/admin/outbound/order-edit', 'id' => $order->id]), 'btn_class' => 'btn btn-xs btn-success', 'tip' => '修改', 'color' => 'green'],
                        ['icon' => 'fa fa-trash', 'href' => Url::to(['/admin/outbound/order-edit', 'api_id' => $order->id]), 'btn_class' => 'btn btn-xs btn-danger', 'tip' => '删除'],
                    ]]);?></td>
            </tr>
        <?php }?>
    </tbody>
</table>
<?php echo LinkPager::widget(['pagination' => $pagination]);?>